package com.example.myapplication.Activity;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.example.myapplication.R;

public class Mine extends AppCompatActivity {
    SharedPreferences sp;
    TextView tv_name, tuichu;
    SharedPreferences.Editor editor;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_mine);
        tv_name = findViewById(R.id.text_name);
        tuichu = findViewById(R.id.tuichu);
        sp = getSharedPreferences("zhanghaomima", Context.MODE_PRIVATE);
        editor = sp.edit();
        String name = sp.getString("zhanghao", "");
        tv_name.setText(name);
        tuichu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                editor.putInt("flag", 0);
                editor.commit();
                // 退出登录后返回MainActivity
                Intent intent = new Intent();
                intent.setClass(Mine.this, MainActivity.class);
                startActivity(intent);
                finish();
            }
        });
    }
}